import javax.swing.*;
import java.awt.*;

public class ShoppingAppMain {
    public static void main(String[] args) {
        EventQueue.invokeLater(() -> {
            try {
                JFrame frame = new JFrame();
                frame.setTitle("二手商品交易平台");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setSize(400, 700);
                frame.setLocationRelativeTo(null);

                CardLayout cardLayout = new CardLayout();
                JPanel cardPanel = new JPanel(cardLayout);

                // 创建各个页面
                ProductListPage productListPage = new ProductListPage(cardLayout, cardPanel);
                ProductDetailPage productDetailPage = new ProductDetailPage(cardLayout, cardPanel);
                PurchaseInfoPage purchaseInfoPage = new PurchaseInfoPage(cardLayout, cardPanel);
                ConfirmPurchasePage confirmPurchasePage = new ConfirmPurchasePage(cardLayout, cardPanel);

                // 添加页面到卡片布局
                cardPanel.add(productListPage, "productList");
                cardPanel.add(productDetailPage, "productDetail");
                cardPanel.add(purchaseInfoPage, "purchaseInfo");
                cardPanel.add(confirmPurchasePage, "confirmPurchase");

                frame.add(cardPanel);
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
}